'use strict';

angular.module('mrDirectives',[])
  .directive('mrNavbar', function ($location) {
        return {
            restrict: 'AC',
            link: function (scope, element, attrs, controller) {
              scope.$watch(function(){ return ($location.path());}, function (newValue, oldValue) {
                $('li[data-match-route]', element).each(function (k, li) {
                  var $li = $(li), pattern = $li.attr('data-match-route'), regexp = new RegExp('^' + pattern + '$', ['i']);
                  if (regexp.test(newValue)) {
                    $li.addClass('active').find('.collapse.in').collapse('hide');
                  } else {
                    $li.removeClass('active');
                  }
                });
              });
            }
          };
      }
    )
angular.module('mrDirectives',[])
  .directive('patient', function(){
    // Runs during compile
    return {
      restrict: 'E',
      template: '<div class="patient">'+
				'<span name="name">{{patient.name}}</span>'+
				'<span name="name">{{patient.surname}}</span>'+
				'<span name="name">{{patient.age}}</span>'+
				'<button ng-click="patientRemove(\'{{patient.id}}\')">Remove Patient</button>'+
				'</div>',
      replace: true,
      tranclude: true,
      // name: '',
      // priority: 1,
      // terminal: true,
      // scope: {}, // {} = isolate, true = child, false/undefined = no change
      // cont­rol­ler: function($scope, $element, $attrs, $transclue) {},
      // require: 'ngModel', // Array = multiple requires, ? = optional, ^ = check parent elements
      // restrict: 'A', // E = Element, A = Attribute, C = Class, M = Comment
      // template: '',
      // templateUrl: '',
      // replace: true,
      // transclude: true,
      // compile: function(tElement, tAttrs, function transclude(function(scope, cloneLinkingFn){ return function linking(scope, elm, attrs){}})),
      link: function($scope, iElm, iAttrs, controller) {
      }
    };
  });


